<html>
<head>
    <title>吉垚物业后台管理系统</title>
    <meta charset="utf-8">
    <link rel="shortcut icon" th:href="./images/favicon.ico" type="image/x-icon">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <!-- 引入css -->
    <link rel="stylesheet" href="./css/plugins/font-awesome-4.7.0/css/font-awesome.min.css"  media="all">
    <link rel="stylesheet" href="./lib/layui-v2.3.0/css/layui.css"  media="all">
    <link rel="stylesheet" href="./css/main.css"  media="all">
    <link rel="stylesheet" href="./css/bootstrap.min.css">
</head>
<body>
<div class="">
    <form action="#">
		  <div class="layui-form-item">
			<label class="layui-form-label">岗位</label>
			<div class="layui-input-inline">
			  <input type="text" name="name" id="name" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
			</div>
		  </div>
        <div class="layui-form-item">
            <label class="layui-form-label">薪资</label>
            <div class="layui-input-inline">
                <input type="text" name="salary" id="salary" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">岗位简介</label>
            <div class="layui-input-inline">
                <input type="text" name="introduction" id="introduction" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">工作地址</label>
            <div class="layui-input-inline">
                <input type="text" name="address" id="address" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">隶属部门</label>
            <div class="layui-input-inline">
                <input type="text" name="department" id="department" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">工作性质</label>
            <div class="layui-input-inline">
                <input type="text" name="natureofwork" id="natureofwork" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">经验要求</label>
            <div class="layui-input-inline">
                <select name="experiences" id="experiences" lay-filter="aihao">
                    <option value="0" id="e0">经验不限</option>
                    <option value="1" id="e1">一年经验以内</option>
                    <option value="2" id="e2">一到三年经验</option>
                    <option value="3" id="e3">三到五年经验</option>
                    <option value="4" id="e4">五年经验以上</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">年龄要求</label>
            <div class="layui-input-inline">
                <select name="age" id="age" lay-filter="aihao">
                    <option value="0" id="a0">年龄不限</option>
                    <option value="1" id="a1">25以下</option>
                    <option value="2" id="a2">35以下</option>
                    <option value="3" id="a3">45以下</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别要求</label>
            <div class="layui-input-inline">
                <select name="sex" id="sex" lay-filter="aihao">
                    <option value="-1" id="s-1">性别不限</option>
                    <option value="0" id="s0">仅限男性</option>
                    <option value="1" id="s1">仅限女性</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">具体描述</label>
            <div class="layui-input-inline">
                <input type="text" name="describes" id="describes" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">福利待遇</label>
            <div class="layui-input-inline">
                <select name="benefit" id="benefit" lay-filter="aihao">
                    <option value="-1" id="b-1">单休</option>
                    <option value="0" id="b0">大小周</option>
                    <option value="1" id="b1">双休</option>
                    <option value="2" id="b2">五险一金，单休</option>
                    <option value="3" id="b3">五险一金，双休</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系方式</label>
            <div class="layui-input-inline">
                <input type="text" name="telephone" id="telephone" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <hr>
        <div class="layui-form-item timo-finally">
            <button class="layui-btn ajax-submit" onclick="updateAdv()"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn btn-secondary close-popup" id="close"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
<script src="./lib/layui-v2.3.0/layui.js" charset="utf-8"></script>
<script src="./js/main.js" charset="utf-8"></script>
<script src="js/plugins/jquery-3.3.1.min.js"></script>
<script src="js/checkToken.js"></script>
</body>
<script type="text/javascript">
    // var category=window.location.search;
    // //截取，获取获得category的具体值
    // var typeid = category.substring(category.lastIndexOf('=')+1, category.length);
    // console.log(category);
    // console.log(cateval);<th>岗位</th>
    var advid=sessionStorage.getItem('advid');
    var name=sessionStorage.getItem('name');
    var salary=sessionStorage.getItem('salary');
    var introduction=sessionStorage.getItem('introduction');
    var address=sessionStorage.getItem('address');
    var department=sessionStorage.getItem('department');
    var natureofwork=sessionStorage.getItem('natureofwork');
    var exp=sessionStorage.getItem('exp');
    var age=sessionStorage.getItem('age');
    var sex=sessionStorage.getItem('sex');
    var describes=sessionStorage.getItem('describes');
    var benefit=sessionStorage.getItem('benefit');
    var telephone=sessionStorage.getItem('telephone');

    $('#e'+exp).attr('selected',true);
    $('#a'+age).attr('selected',true);
    $('#s'+sex).attr('selected',true);
    $('#b'+benefit).attr('selected',true);

    $('#name').val(name);
    $('#salary').val(salary);
    $('#introduction').val(introduction);
    $('#address').val(address);
    $('#department').val(department);
    $('#natureofwork').val(natureofwork);
    $('#describes').val(describes);
    $('#telephone').val(telephone);

    function updateAdv() {
        name=$('#name').val();
        salary=$('#salary').val();
        introduction=$('#introduction').val();
        address=$('#address').val();
        department=$('#department').val();
        natureofwork=$('#natureofwork').val();
        experiences=$('#experiences').val();
        agelimit=$('#age').val();
        sex=$('#sex').val();
        describes=$('#describes').val();
        benefit=$('#benefit').val();
        telephone=$('#telephone').val();
        var formdata=new FormData();
        formdata.append('id',advid);
        formdata.append('name',name);
        formdata.append('salary',salary);
        formdata.append('introduction',introduction);
        formdata.append('address',address);
        formdata.append('department',department);
        formdata.append('natureofwork',natureofwork);
        formdata.append('experiences',experiences);
        formdata.append('agelimit',agelimit);
        formdata.append('sex',sex);
        formdata.append('describes',describes);
        formdata.append('benefit',benefit);
        formdata.append('telephone',telephone);
        $.ajax({
            url:'http://localhost:8081/admin/updateAdv.do',
            headers:{
                accessToken:localStorage.getItem('accessToken')
            },
            type: "post",
            data: formdata,
            contentType: false,
            processData: false,
            success:function (data) {
                checkToken(data)
                if (data.resMsg!='更新失败'){
                    top.location.reload();
                    this.close();
                }else{
                    alert('更新失败');
                }
            }
        })
    }

</script>
</html>